@extends('layouts.app')
@section('head')
    <style>
        card-header.a{
          margin-left: 20px;

        }
    </style>
@endsection

@section('content')
<div class="container">
    @include('home._banner')
    <div class="card-header">
        <table class="table table-bordered table-striped">
            <thead>
            <tr>
                <th width="45%">名称</th>
                <th width="7%">优惠券</th>
                <th width="8%">分类</th>
                <th>图片</th>
                <th width="7%">售价</th>
                <th width="10%">访问人/次数</th>
                <th width="10%">操作</th>
            </tr>
            </thead>
            <tbody>
            @forelse($lists as $lv)
                <tr>
                    <td>{{$lv['name'] or ''}}</td>
                    <td>{{$lv['coupon'] or ''}}</td>
                    <td>{{$lv->belongsToType->name or '特别推荐'}}</td>
                    <td>
                        @if(!empty($lv['img']['0']))

                            @foreach($lv['img'] as $item)
                                <a href="{{ url($item) }}" target="_blank">
                                    <img src="{{ url($item) }}" style="width: 40px;height: 60px" alt="">
                                </a>
                            @endforeach
                        @endif
                    </td>
                    <td>{{$lv['price'] or ''}}</td>
                    <td>{{$lv->hasManyRecord->count() ?? 0}}</td>
                    <td>
                        <a class="G-color-blue" href="{!! url('home/create',['id'=>$lv['id']]) !!}">编辑</a>
                        <a class="G-color-blue" href="{!! url('home/delete',['id'=>$lv['id']]) !!}">删除</a>
                    </td>
                </tr>
            @empty
                <tr><td colspan="7">暂时没有任何数据</td> </tr>
            @endforelse
            </tbody>
        </table>
        @if(!$lists->isEmpty())
            {!! $lists->appends(request()->all())  !!}
        @endif

    </div>
</div>
@endsection
